runner: make PYTEST_CURRENT_TEST thread-safe with threading.local()#13982
Closed
CortexShadow wants to merge 1 commit intopytest-dev:mainfrom
Closed
runner: make PYTEST_CURRENT_TEST thread-safe with threading.local()#13982CortexShadow wants to merge 1 commit intopytest-dev:mainfrom
CortexShadow wants to merge 1 commit intopytest-dev:mainfrom
Conversation
ac7bcd8 to
15a32cc
Compare
use module-level threading.local() for per-thread isolation preserve os.environ for external debugging tools add multi-threaded tests
2918027 to
020219c
Compare
Member
|
The thread local you are adding doesn't do anything, and a thread local can't be used to fix the issue at hand. You might be misunderstanding the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13844
PYTEST_CURRENT_TESTis now properly thread-safe for the upcoming native multi-threaded test execution.threading.local()to isolate the current test per threados.environ["PYTEST_CURRENT_TEST"]is still updated and always cleaned up, so only hung tests remain visible inhtop/psAdded tests for concurrent execution and full cleanup verification.
Note: Codecov shows 84% because the FALSE branch of
if hasattr(_current_test_local, "value")is uncovered. This branchonly occurs if teardown runs without setup on a fresh thread, which doesn't happen in practice. All functional paths are
tested.